<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "chat_record".
 *
 * @property integer $id
 * @property string $comment
 * @property integer $sender
 * @property integer $receiver
 * @property string $sender_name
 * @property string $receiver_name
 * @property integer $push_type
 * @property integer $ctime
 * @property integer $is_valid
 * @property integer $state
 */
class ChatRecord extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'chat_record';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['comment'], 'string'],
            [['sender', 'receiver', 'push_type', 'ctime', 'is_valid', 'state'], 'integer'],
            [['sender_name', 'receiver_name'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'comment' => 'Comment',
            'sender' => 'Sender',
            'receiver' => 'Receiver',
            'sender_name' => 'Sender Name',
            'receiver_name' => 'Receiver Name',
            'push_type' => 'Push Type',
            'ctime' => 'Ctime',
            'is_valid' => 'Is Valid',
            'state' => 'State',
        ];
    }
    public function getSessionList($condition){
        $result = (new \yii\db\Query())
                ->select('*')
                ->from('chat_record')
                ->where($condition)
                ->all();
        return $result;
    }
    public function getSession($condition,$orCondition){
        $result = (new \yii\db\Query())
                ->select('*')
                ->from('chat_record')
                ->where($condition)
                ->orWhere($orCondition)
                ->all();
        return $result;
    }
    
}
